package org.openstreetmap.gui.jmapviewer;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.geom.Line2D;

/**
 * Created by: Eduardo Quintana Contreras
 * Date: 2/02/12
 * Time: 04:10 PM
 */
public class MapRoute {
	double lat1, lat2;
	double lon1, lon2;
	Color color;
	int mapRouteID;
	int mapStartLocationID, mapEndLocationID;

	public MapRoute(double lat1, double lon1, double lat2, double lon2, int mapRouteID, int mapStartLocationID,
	                int mapEndLocationID) {
		this(new Color(0, 255, 0, 100), lat1, lon1, lat2, lon2, mapRouteID, mapStartLocationID, mapEndLocationID);
	}

	public MapRoute(Color color, double lat1, double lon1, double lat2, double lon2, int mapRouteID,
	                int mapStartLocationID, int mapEndLocationID) {
		this.color = color;
		this.lat1 = lat1;
		this.lon1 = lon1;
		this.lat2 = lat2;
		this.lon2 = lon2;
		this.mapRouteID = mapRouteID;
		this.mapStartLocationID = mapStartLocationID;
		this.mapEndLocationID = mapEndLocationID;
	}

	public double getLat1() {
		return lat1;
	}

	public double getLon1() {
		return lon1;
	}

	public double getLat2() {
		return lat2;
	}

	public double getLon2() {
		return lon2;
	}

	public int getMapRouteID() {
		return mapRouteID;
	}

	public int getMapStartLocationID() {
		return mapStartLocationID;
	}

	public int getMapEndLocationID() {
		return mapEndLocationID;
	}

	public void paint(Graphics g, Point position1, Point position2) {
		Graphics2D g2 = (Graphics2D) g;
		g2.setColor(color);
		g2.setStroke(new BasicStroke(5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
		g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
		g2.draw(new Line2D.Float(position1.x, position1.y, position2.x, position2.y));
	}
}
